<?php
/**
 * Generic template for Archive pages.
 *
 * Used to display archive-type pages if nothing more specific matches a query.
 * For example, puts together date-based pages if no date.php file exists.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package dkret3
 * @since 3.6
 */

get_header(); ?>

   <div id="container">

        <?php /* dkret3 Hook */ do_action( 'dkret_before_container' ); ?>

        <div id="content" role="main">

            <?php /* dkret3 Hook */ do_action( 'dkret_before_content' ); ?>

            <?php the_post() ?>

            <?php if ( is_day() ) : ?>
                <h2 class="page-title"><?php printf( __( 'Daily Archives: <span>%s</span>', 'dkret' ), get_the_date() ); ?></h2>
            <?php elseif ( is_month() ) : ?>
                <h2 class="page-title"><?php printf( __( 'Monthly Archives: <span>%s</span>', 'dkret' ), get_the_date('F Y') ); ?></h2>
            <?php elseif ( is_year() ) : ?>
                <h2 class="page-title"><?php printf( __( 'Yearly Archives: <span>%s</span>', 'dkret' ), get_the_date('Y') ) ?></h2>
            <?php endif; ?>

            <?php rewind_posts(); ?>

            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

				<?php if ( 'gallery' == get_post_format( $post->ID ) ) : // show post as gallery for gallery category
                    $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
                    $total_images = count( $images );
                    $image = array_shift( $images );
                ?>

                    <div id="post-<?php the_ID(); ?>" <?php post_class( 'gallery-post' ); ?>>

                        <?php /* dkret3 Hook */ do_action( 'dkret_before_entry' ); ?>

                        <div class="entry-summary">

                            <?php if ( $total_images > '0' ) : ?>
                                            <div class="entry-image wp-caption">
                                                <a href="<?php the_permalink(); ?>"><?php echo wp_get_attachment_image( $image->ID, 'thumbnail' ); ?></a>
                                                <p class="wp-caption-text"><?php printf( __( 'This album contains <strong>%s</strong> items.', 'dkret' ), $total_images ); ?></p>
                                            </div>
                            <?php endif; ?>

                            <?php the_excerpt( '' ); ?>
                            
                        </div><!-- .entry-summary -->

                        <?php /* dkret3 Hook */ do_action( 'dkret_after_entry' ); ?>
                        
                    </div><!-- #post-<?php the_ID(); ?> -->
                    
                <?php else : ?>

                    <div id="post-<?php the_ID() ?>" <?php post_class() ?>>

                        <?php /* dkret3 Hook */ do_action( 'dkret_before_entry' ); ?>

                        <?php if ( get_dkret_option( 'summary' ) ) : //Display Excerpts if Option is set ?>

                            <div class="entry-summary">
                            
                                <?php the_excerpt( __( 'Continue reading <span class="meta-nav">&raquo;</span>', 'dkret' ) ); ?>

                            </div><!-- .entry-summary -->

                        <?php else : ?>

                            <div class="entry-content">

                                <?php the_content( __( 'Continue reading <span class="meta-nav">&raquo;</span>', 'dkret' ) ); ?>

                                <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'dkret' ), 'after' => '</div>' ) ); ?>

                            </div><!-- .entry-content -->

                        <?php endif; ?>

                        <?php /* dkret3 Hook */ do_action( 'dkret_after_entry' ); ?>
                
                    </div><!-- #post-ID -->
                    
                <?php endif; ?>

            <?php endwhile; ?>

            <?php else: ?>

                <p class="no-data">
                    <?php _e( 'Sorry, there are no posts in this archive.', 'dkret' ); ?>
                </p><!-- .no-data -->

            <?php endif; ?>

            <?php /* dkret3 Hook */ do_action( 'dkret_after_content' ); ?>
            
        </div><!-- #content -->

        <?php /* dkret3 Hook */ do_action( 'dkret_after_container' ); ?>

    </div><!-- #container -->

<?php get_sidebar() ?>
<?php get_footer() ?>